// Yang Shuai  Copyright (c) 2022 https://yby6.com.
// Copyright (c) 2022. Yangbuyi, personal projects are not allowed to be commercialized without permission.
// Please keep the information of the original author of the code. Thank you
//

package com.leetroll.common.constant;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class AliyunConstant implements InitializingBean {

    /**
     * 地区
     */
    @Value("${aliyun.regionId}")
    private String regionId;

    /**
     * 访问密钥id
     */
    @Value("${aliyun.accessKey}")
    private String accessKeyId;

    /**
     * 访问密钥的秘密
     */
    @Value("${aliyun.accessSecret}")
    private String accessKeySecret;

    /**
     * endpoint
     */
    @Value("${aliyun.endpoint}")
    private String endpoint;
    /**
     * endpoint
     */
    @Value("${aliyun.cdnEndpoint}")
    private String cdnEndpoint;

    @Value("${aliyun.bucket}")
    private String bucket;

    public static String REGION_ID;
    public static String ACCESS_KEY;
    public static String ACCESS_SECRET;
    public static String ENDPOINT;
    public static String CDN_ENDPOINT;
    public static String BUCKET;

    /**
     * 在属性文件加载完毕后属性也设置完毕之后, 会自动调用
     */
    @Override
    public void afterPropertiesSet() {
        REGION_ID = regionId;
        ACCESS_KEY = accessKeyId;
        ACCESS_SECRET = accessKeySecret;
        ENDPOINT = endpoint;
        CDN_ENDPOINT = cdnEndpoint;
        BUCKET = bucket;
    }
}